#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	int size = 0;

	while (s != t)
	{
		if (size == 5500)
			break;
		//
		for (int i = 0; i < s.size(); i++)
		{
			if (s[i] >= 'a' && s[i] <= 'z')
			{
				if (s[i] == 'z')
					s[i] = 'a';
				else
					s[i] += 1;
			}
			else
			{
				if (s[i] == '9')
					s[i] = '0';
				else
					s[i] += 1;
			}
		}
		size++;
	}
	if (s == t)
		cout << size;
	else
		cout << "IMPOSSIBLE";
}